﻿@{
    Layout = "";
}
@model Nop.Plugin.Shipping.FixedOrByWeight.Models.ConfigurationModel

<div class="row">
    <div class="col-md-3">
        <div class="onoffswitch">
            <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="advanced-settings-mode" checked="@Model.ShippingByWeightEnabled">
            <label class="onoffswitch-label" for="advanced-settings-mode">
                <span class="onoffswitch-inner"
                          data-locale-basic="@T("Plugins.Shipping.FixedOrByWeight.Fixed")"
                          data-locale-advanced="@T("Plugins.Shipping.FixedOrByWeight.ShippingByWeight")"></span>
                <span class="onoffswitch-switch"></span>
            </label>
        </div>
    </div>
    <div class="col-md-9">
        <div class="pull-right">
            <a href="@Url.Action("Methods", "Shipping", new {area = "Admin"})" class="btn bg-blue">
                <i class="fa fa-truck"></i>
                @T("Admin.Configuration.Shipping.Methods.Manage")
            </a>
            <a href="@Url.Action("Restrictions", "Shipping", new {area = "Admin"})" class="btn bg-blue">
                <i class="fa fa-globe"></i>
                @T("Admin.Configuration.Shipping.Restrictions.Manage")
            </a>
        </div>
    </div>
</div>

<script type="text/javascript">
    function checkAdvancedSettingsMode(advanced) {
        if (advanced) {
            $("body").addClass("advanced-settings-mode");
            $("body").removeClass("basic-settings-mode");
        } else {
            $("body").removeClass("advanced-settings-mode");
            $("body").addClass("basic-settings-mode");
        }
    }

    checkAdvancedSettingsMode($("#advanced-settings-mode").is(':checked'));
    $(document)
        .ready(function() {
            $("#advanced-settings-mode")
                .click(function() {
                    checkAdvancedSettingsMode($(this).is(':checked'));
                    $.ajax({
                        cache: false,
                        url: '@Url.Action("SaveMode", "FixedOrByWeight")',
                        type: 'post',
                        data: { value: $(this).is(':checked') },
                        dataType: 'json',
                        error: function(xhr, ajaxOptions, thrownError) {
                            alert('Failed to save preferences.');
                        }
                    });
                });
        });
</script>

@Html.Partial("~/Plugins/Shipping.FixedOrByWeight/Views/_FixedRate.cshtml")
@Html.Partial("~/Plugins/Shipping.FixedOrByWeight/Views/_ByWeight.cshtml", Model)